<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('大区会长档案列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <input id="storeId" name="storeId" th:value="${id}" class="form-control" type="hidden">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label style="width: 120px;">大区会长名称：</label>
                                <input type="text" name="agentName"/>
                            </li>
                            <li>
                                <label>联系人：</label>
                                <input type="text" name="agentPerson"/>
                            </li>
                            <li>
                                <label>联系方式：</label>
                                <input type="text" name="agentPhone"/>
                            </li>
                            <li>
                                <label>联系地址：</label>
                                <input type="text" name="agentAddress"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="col-sm-12 select-table table-bordered">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('zsyh:agentinfo:edit')}]];
        var removeFlag = [[${@permission.hasPermi('zsyh:agentinfo:remove')}]];
        var agentValidDatas = [[${@dict.getType('validate_state')}]];
        var prefix = ctx + "zsyh/agentinfo";

        $(function() {
            var options = {
                url: prefix + "/list?agentValid=1",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                sidePagination: "server",
                pagination: true,
                paginationLoop: false,
                pageSize: 8,
                pageNumber: 1,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                modalName: "大区会长档案",
                onClickRow: onClickRow,
                columns: [{
                    radio: true
                },{
                    field : 'Number',
                    title : '序号',
                    align: 'center',
                    width: 20,
                    formatter : function(value, row, index) {
                        var pageSize = $('#bootstrap-table').bootstrapTable('getOptions').pageSize;//通过表的#id 可以得到每页多少条
                        var pageNumber = $('#bootstrap-table').bootstrapTable('getOptions').pageNumber;//通过表的#id 可以得到当前第几页
                        return pageSize * (pageNumber - 1) + index + 1;//返回每条的序号： 每页条数 * （当前页 - 1 ）+ 序号
                    }
                },
                {
                    field: 'id',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'agentName',
                    align: 'center',
                    title: '大区会长名称'
                },
                {
                    field: 'agentPerson',
                    align: 'center',
                    title: '联系人'
                },
                {
                    field: 'agentPhone',
                    align: 'center',
                    title: '联系方式'
                },
                {
                    field: 'agentDetailAddress',
                    align: 'center',
                    title: '联系地址'
                },
                {
                    field: 'agentValid',
                    align: 'center',
                    title: '有效状态',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(agentValidDatas, value);
                    }
                }]
            };
            $.table.init(options);
        });


        function onClickRow(row,$element) {
            $element[0].firstElementChild.firstElementChild.click();
        }

        function submitHandler() {
            debugger;
            var rows=$('#bootstrap-table').bootstrapTable('getSelections');
            $.modal.confirm("确认要归属为此大区会长吗？", function() {
                $.operate.post(ctx + "zsyh/repairStore/lockAgent", { "storeId":$("#storeId").val(),"operatorId":rows[0].id},function () {
                    parent.lockAfter();
                    $.modal.close();
                });
            })
        }

    </script>
</body>
</html>